package com.example.gaodetest.locatorcallback;

import com.amap.api.maps.LocationSource;
import com.example.gaodetest.bean.LocationBean;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;

import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import ohos.location.Location;
import ohos.location.LocatorCallback;

/**
 * 上报设备位置信息
 */
public class MylocatorCallBack implements LocatorCallback {

    private Context context;

    private static final HiLogLabel hilog = new HiLogLabel(HiLog.DEBUG, 0x0000, "APP_LOG");

    // 启动定位服务后，获取定位结果并上报
    @Override
    public void onLocationReport(Location location) {
        setLoation(location);

    }

    //添加定位信息
    public void setLoation(Location location){
       if (location != null){
            //获取location
           HiLog.info(hilog,"setLoation获取经纬度：" + location.getLatitude() + "," + location.getLongitude());

       } else {
            new ToastDialog(context).setText("定位事件未响应").show();
        }
    }


    @Override
    public void onStatusChanged(int i) {

    }

    @Override
    public void onErrorReport(int i) {

    }
}
